﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典目录管理</title>
    <#--<#include "../common/link.ftl" >-->
    <#include "../common/link.ftl" ><#--freemarker 的include,包含另一个
    模板文件,需要使用相对当前的模板文件的路径,再去找另一个模板-->
    <script>
        $(function () {
            //添加/编辑
            $('.btn-input').click(function () {
                //清空表单数据,防止点击完编辑后,点添加会带有id,有id就又是编辑了
                $('#editForm')[0].reset();
                //获取当前数据源里的数据
                var json = $(this).data('json');
                //回显数据
                if (json){
                    $('#editForm input[name=id]').val(json.id);
                    $('#editForm input[name=title]').val(json.title);
                    $('#editForm input[name=sn]').val(json.sn);
                    $('#editForm input[name=intro]').val(json.intro);
                }
                //弹出模态框
                $('#inputModal').modal('show');
            });
            $('.btn-submit').click(function () {
                /*var param = $('#editForm').serialize();
                $.post('/systemdictionary/saveOrUpdate.do',param,handlerMessage);*/
                /*$('#editForm').ajaxSubmit(handlerMessage);*/
                $('#editForm').ajaxForm(handlerMessage);
            });
        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#--<#include "../common/navbar.ftl" >-->
        <#include "../common/navbar.ftl" >
    <!--菜单回显-->
    <#--<c:set var="currentMenu" value="systemdictionary"/>-->
        <#assign currentMenu="systemdictionary" />
    <#--<#include "../common/menu.ftl" >-->
        <#include "../common/menu.ftl" >
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典目录管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/systemDictionary/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>字典目录标题</th>
                            <th>字典目录编号</th>
                            <th>字典目录简介</th>
                            <th>操作</th>
                        </tr>
                        <#list pageResult.list as systemdictionary>
                            <tr>
                                <td>${systemdictionary_index+1}</td>
                                <td>${systemdictionary.title}</td>
                                <td>${systemdictionary.sn}</td>
                                <td>${systemdictionary.intro}</td>
                                <td>
                                    <a href="#" data-json='${(systemdictionary.json)!}' class="btn btn-info btn-xs btn-input" >
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                </td>
                            </tr>
                        </#list>
                    </table>

                    <!--分页-->
                    <div style="text-align: center;">
                        <ul id="pagination" class="pagination"></ul>
                    </div>
                    <script>
                        $("#pagination").twbsPagination({
                            totalPages:${pageResult.pages}, /*// 拿到总页数*/
                            visiblePages: 5, /*// 有5个页的格子*/
                            startPage:${pageResult.pageNum},/*// 拿到当前页*/

                            first: "首页",
                            prev: "上页",
                            next: "下页",
                            last: "尾页",
                            onPageClick: function (event, page) { //点击页码的时候会执行的方法
                                $("#currentPage").val(page);
                                $("#searchForm").submit();
                            }
                        });
                    </script>
                </div>
            </div>
        </section>
    </div>
    <#--<#include "../common/footer.ftl" >-->
    <#include "../common/footer.ftl" >
</div>
<!-- Modal -->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">字典目录新增/编辑</h4>
            </div>
            <form class="form-horizontal" action="/systemDictionary/saveOrUpdate.do" method="post" id="editForm">
                <div class="modal-body">
                        <input type="text" name="id" hidden>
                        <div class="form-group" style="margin-top: 10px;">
                            <label for="title" class="col-sm-3 control-label">标题：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" id="name" name="title"
                                       placeholder="请输入字典目录名">
                            </div>
                        </div>
                        <div class="form-group" style="margin-top: 10px;">
                            <label for="sn" class="col-sm-3 control-label">编码：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" id="sn" name="sn"
                                       placeholder="请输入字典目录编码">
                            </div>
                        </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="intro" class="col-sm-3 control-label">简介：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sn" name="intro"
                                   placeholder="请输入字典目录编码">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary btn-submit">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
